var ns;
var app = new Vue({
    el: '#app',
    data: {
        form: {
            ID: 0,
        },
    },
    methods: {
        get_data: function() {
            var that = this;
            ns.post({
                action: 'getscanvisitqrcodedata',
                ID: that.form.ID
            }, function (succeed, data, err) {
                if (succeed) {
                    that.form = data.item;
                    if (that.form.UseStatus != undefined && that.form.UseStatus != 1) {
                        api.alert({
                            title: '提示',
                            msg: '当前链接未生效或已失效,请重新选择',
                        }, function () {
                            api.closeWin();
                        });
                        return;
                    }
                } else if (err) {
                    api.toast({
                        msg: err,
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            });
        },
        do_current: function() {
            var that = this;
            api.confirm({
                title: '提示',
                msg: '确认是否通行?',
                buttons: ['确定通行', '取消']
            }, function(ret, err) {
                if (ret.buttonIndex==1) {
                    ns.post({
                        action: 'savescanvisitlog',
                        ID: that.form.ID,
                    }, function(succeed, data, err) {
                        if (succeed) {
                            api.toast({
                                msg: '操作成功',
                                duration: 2000,
                                location: 'bottom'
                            });
                        } else if (err) {
                            api.toast({
                                msg: err,
                                duration: 2000,
                                location: 'bottom'
                            });
                        }
                        setTimeout(function () {
                            api.closeWin();
                        }, 500);
                    });
                }
            });
        },
    }
});
apiready = function() {
    api.parseTapmode();
    app.form.ID = api.pageParam.id; //二维码传值
    ns = window.Foresight.Util;
    app.get_data();
    setTimeout(function() {
        api.closeFrame({
            name: 'scanner_frm'
        });
    }, 500);
}
